import { mgop } from '@aligov/jssdk-mgop'
import router from '@/router'
import cookie from '@/common/js/cookie'




function http(obj) {
	
	return new Promise((resolve, reject) => {
		
		let data = obj.data || obj.params || {}
		let method = obj.method || 'GET'
		let url = obj.url
		
		mgop({
			api: url, // 必须
			host: 'https://mapi.zjzwfw.gov.cn/',
			dataType: 'JSON',
			type: method,
			appKey: 'qaahrh82+2001825973+hjhcvd', // 必须
			data: data,
			header: {
				isTestUrl: true, //true=>测试
				token: cookie.get(process.env.VUE_APP_BASE_TOKEN)
			},
			onSuccess: json => {
				resolve(json)
			},
			onFail: err => {
				reject(err)
			}
		})
		
	})
	
}

export default http
